<!DOCTYPE html>



  


<html class="theme-next gemini use-motion" lang="zh-Hans">
<head>
  <meta charset="UTF-8"/>
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1"/>
<meta name="theme-color" content="#222">



  
  
    
    
  <script src="/lib/pace/pace.min.js?v=1.0.2"></script>
  <link href="/lib/pace/pace-theme-minimal.min.css?v=1.0.2" rel="stylesheet">







<meta http-equiv="Cache-Control" content="no-transform" />
<meta http-equiv="Cache-Control" content="no-siteapp" />
















  
  
  <link href="/lib/fancybox/source/jquery.fancybox.css?v=2.1.5" rel="stylesheet" type="text/css" />







<link href="/lib/font-awesome/css/font-awesome.min.css?v=4.6.2" rel="stylesheet" type="text/css" />

<link href="/css/main.css?v=5.1.4" rel="stylesheet" type="text/css" />


  <link rel="apple-touch-icon" sizes="180x180" href="/images/apple-touch-icon-next.png?v=5.1.4">


  <link rel="icon" type="image/png" sizes="32x32" href="/images/favicon-32x32-next.png?v=5.1.4">


  <link rel="icon" type="image/png" sizes="16x16" href="/images/favicon-16x16-next.png?v=5.1.4">


  <link rel="mask-icon" href="/images/logo.svg?v=5.1.4" color="#222">





  <meta name="keywords" content="git," />





  <link rel="alternate" href="/atom.xml" title="搁浅丶岁月的变迁" type="application/atom+xml" />






<meta name="description" content="githug git练习小工具  githug这个命令行工具被设计来练习你的 Git 技能，它把平常可能遇到的一些场景都实例化，变成一个一个的关卡，一共有 55 个关卡，所以将他形象的形容为 Git 游戏。  安装githug1sudo gem install githug ) 游戏开始直接输入githug，再输入y，创建githug文件夹，就开始游戏了1githug  第一关根据提示初始化git">
<meta name="keywords" content="git">
<meta property="og:type" content="article">
<meta property="og:title" content="7.githug - git练习小工具">
<meta property="og:url" content="http://yoursite.com/2017/12/25/2017-12-25-7.githug - git练习小工具/index.html">
<meta property="og:site_name" content="搁浅丶岁月的变迁">
<meta property="og:description" content="githug git练习小工具  githug这个命令行工具被设计来练习你的 Git 技能，它把平常可能遇到的一些场景都实例化，变成一个一个的关卡，一共有 55 个关卡，所以将他形象的形容为 Git 游戏。  安装githug1sudo gem install githug ) 游戏开始直接输入githug，再输入y，创建githug文件夹，就开始游戏了1githug  第一关根据提示初始化git">
<meta property="og:locale" content="zh-Hans">
<meta property="og:image" content="https://github.com/zhangyongguang/learn-githug/raw/master/images/%E5%B1%8F%E5%B9%95%E5%BF%AB%E7%85%A7%202017-02-19%20%E4%B8%8B%E5%8D%8812.57.50.png">
<meta property="og:image" content="https://github.com/zhangyongguang/learn-githug/raw/master/images/%E5%B1%8F%E5%B9%95%E5%BF%AB%E7%85%A7%202017-02-19%20%E4%B8%8B%E5%8D%881.11.27.png">
<meta property="og:image" content="https://github.com/zhangyongguang/learn-githug/raw/master/images/%E5%B1%8F%E5%B9%95%E5%BF%AB%E7%85%A7%202017-02-19%20%E4%B8%8B%E5%8D%881.16.19.png">
<meta property="og:image" content="https://github.com/zhangyongguang/learn-githug/raw/master/images/%E5%B1%8F%E5%B9%95%E5%BF%AB%E7%85%A7%202017-02-19%20%E4%B8%8B%E5%8D%881.22.35.png">
<meta property="og:image" content="https://github.com/zhangyongguang/learn-githug/raw/master/images/%E5%B1%8F%E5%B9%95%E5%BF%AB%E7%85%A7%202017-02-19%20%E4%B8%8B%E5%8D%881.29.17.png">
<meta property="og:image" content="https://github.com/zhangyongguang/learn-githug/raw/master/images/%E5%B1%8F%E5%B9%95%E5%BF%AB%E7%85%A7%202017-02-19%20%E4%B8%8B%E5%8D%881.34.16.png">
<meta property="og:image" content="https://github.com/zhangyongguang/learn-githug/raw/master/images/%E5%B1%8F%E5%B9%95%E5%BF%AB%E7%85%A7%202017-02-19%20%E4%B8%8B%E5%8D%881.37.27.png">
<meta property="og:image" content="https://github.com/zhangyongguang/learn-githug/raw/master/images/%E5%B1%8F%E5%B9%95%E5%BF%AB%E7%85%A7%202017-02-19%20%E4%B8%8B%E5%8D%881.39.59.png">
<meta property="og:image" content="https://github.com/zhangyongguang/learn-githug/raw/master/images/%E5%B1%8F%E5%B9%95%E5%BF%AB%E7%85%A7%202017-02-19%20%E4%B8%8B%E5%8D%881.41.41.png">
<meta property="og:image" content="https://github.com/zhangyongguang/learn-githug/raw/master/images/%E5%B1%8F%E5%B9%95%E5%BF%AB%E7%85%A7%202017-02-19%20%E4%B8%8B%E5%8D%881.48.07.png">
<meta property="og:image" content="https://github.com/zhangyongguang/learn-githug/raw/master/images/%E5%B1%8F%E5%B9%95%E5%BF%AB%E7%85%A7%202017-02-19%20%E4%B8%8B%E5%8D%881.56.55.png">
<meta property="og:image" content="https://github.com/zhangyongguang/learn-githug/raw/master/images/%E5%B1%8F%E5%B9%95%E5%BF%AB%E7%85%A7%202017-02-19%20%E4%B8%8B%E5%8D%882.01.42.png">
<meta property="og:image" content="https://github.com/zhangyongguang/learn-githug/raw/master/images/%E5%B1%8F%E5%B9%95%E5%BF%AB%E7%85%A7%202017-02-19%20%E4%B8%8B%E5%8D%886.32.43.png">
<meta property="og:image" content="https://github.com/zhangyongguang/learn-githug/raw/master/images/%E5%B1%8F%E5%B9%95%E5%BF%AB%E7%85%A7%202017-02-19%20%E4%B8%8B%E5%8D%886.37.32.png">
<meta property="og:image" content="https://github.com/zhangyongguang/learn-githug/raw/master/images/%E5%B1%8F%E5%B9%95%E5%BF%AB%E7%85%A7%202017-02-19%20%E4%B8%8B%E5%8D%886.40.05.png">
<meta property="og:image" content="https://github.com/zhangyongguang/learn-githug/raw/master/images/%E5%B1%8F%E5%B9%95%E5%BF%AB%E7%85%A7%202017-02-19%20%E4%B8%8B%E5%8D%886.40.05.png">
<meta property="og:image" content="https://github.com/zhangyongguang/learn-githug/raw/master/images/%E5%B1%8F%E5%B9%95%E5%BF%AB%E7%85%A7%202017-02-19%20%E4%B8%8B%E5%8D%886.46.39.png">
<meta property="og:image" content="https://github.com/zhangyongguang/learn-githug/raw/master/images/%E5%B1%8F%E5%B9%95%E5%BF%AB%E7%85%A7%202017-02-19%20%E4%B8%8B%E5%8D%886.48.53.png">
<meta property="og:image" content="https://github.com/zhangyongguang/learn-githug/raw/master/images/%E5%B1%8F%E5%B9%95%E5%BF%AB%E7%85%A7%202017-02-19%20%E4%B8%8B%E5%8D%886.50.52.png">
<meta property="og:image" content="https://github.com/zhangyongguang/learn-githug/raw/master/images/%E5%B1%8F%E5%B9%95%E5%BF%AB%E7%85%A7%202017-02-19%20%E4%B8%8B%E5%8D%886.53.43.png">
<meta property="og:image" content="https://github.com/zhangyongguang/learn-githug/raw/master/images/%E5%B1%8F%E5%B9%95%E5%BF%AB%E7%85%A7%202017-02-19%20%E4%B8%8B%E5%8D%886.58.52.png">
<meta property="og:image" content="https://github.com/zhangyongguang/learn-githug/raw/master/images/%E5%B1%8F%E5%B9%95%E5%BF%AB%E7%85%A7%202017-02-19%20%E4%B8%8B%E5%8D%887.02.47.png">
<meta property="og:image" content="https://github.com/zhangyongguang/learn-githug/raw/master/images/%E5%B1%8F%E5%B9%95%E5%BF%AB%E7%85%A7%202017-02-19%20%E4%B8%8B%E5%8D%887.11.59.png">
<meta property="og:image" content="https://github.com/zhangyongguang/learn-githug/raw/master/images/%E5%B1%8F%E5%B9%95%E5%BF%AB%E7%85%A7%202017-02-19%20%E4%B8%8B%E5%8D%887.15.01.png">
<meta property="og:image" content="https://github.com/zhangyongguang/learn-githug/raw/master/images/%E5%B1%8F%E5%B9%95%E5%BF%AB%E7%85%A7%202017-02-19%20%E4%B8%8B%E5%8D%887.22.03.png">
<meta property="og:image" content="https://github.com/zhangyongguang/learn-githug/raw/master/images/%E5%B1%8F%E5%B9%95%E5%BF%AB%E7%85%A7%202017-02-19%20%E4%B8%8B%E5%8D%887.23.48.png">
<meta property="og:image" content="https://github.com/zhangyongguang/learn-githug/raw/master/images/%E5%B1%8F%E5%B9%95%E5%BF%AB%E7%85%A7%202017-02-19%20%E4%B8%8B%E5%8D%887.25.36.png">
<meta property="og:image" content="https://github.com/zhangyongguang/learn-githug/raw/master/images/%E5%B1%8F%E5%B9%95%E5%BF%AB%E7%85%A7%202017-02-19%20%E4%B8%8B%E5%8D%887.28.05.png">
<meta property="og:image" content="https://github.com/zhangyongguang/learn-githug/raw/master/images/%E5%B1%8F%E5%B9%95%E5%BF%AB%E7%85%A7%202017-02-19%20%E4%B8%8B%E5%8D%887.29.54.png">
<meta property="og:image" content="https://github.com/zhangyongguang/learn-githug/raw/master/images/%E5%B1%8F%E5%B9%95%E5%BF%AB%E7%85%A7%202017-02-19%20%E4%B8%8B%E5%8D%887.32.27.png">
<meta property="og:image" content="https://github.com/zhangyongguang/learn-githug/raw/master/images/%E5%B1%8F%E5%B9%95%E5%BF%AB%E7%85%A7%202017-02-19%20%E4%B8%8B%E5%8D%887.38.59.png">
<meta property="og:image" content="https://github.com/zhangyongguang/learn-githug/raw/master/images/%E5%B1%8F%E5%B9%95%E5%BF%AB%E7%85%A7%202017-02-19%20%E4%B8%8B%E5%8D%887.44.24.png">
<meta property="og:image" content="https://github.com/zhangyongguang/learn-githug/raw/master/images/%E5%B1%8F%E5%B9%95%E5%BF%AB%E7%85%A7%202017-02-19%20%E4%B8%8B%E5%8D%888.37.42.png">
<meta property="og:image" content="https://github.com/zhangyongguang/learn-githug/raw/master/images/%E5%B1%8F%E5%B9%95%E5%BF%AB%E7%85%A7%202017-02-19%20%E4%B8%8B%E5%8D%888.39.24.png">
<meta property="og:image" content="https://github.com/zhangyongguang/learn-githug/raw/master/images/%E5%B1%8F%E5%B9%95%E5%BF%AB%E7%85%A7%202017-02-19%20%E4%B8%8B%E5%8D%888.40.59.png">
<meta property="og:image" content="https://github.com/zhangyongguang/learn-githug/raw/master/images/%E5%B1%8F%E5%B9%95%E5%BF%AB%E7%85%A7%202017-02-19%20%E4%B8%8B%E5%8D%888.45.06.png">
<meta property="og:image" content="https://github.com/zhangyongguang/learn-githug/raw/master/images/%E5%B1%8F%E5%B9%95%E5%BF%AB%E7%85%A7%202017-02-19%20%E4%B8%8B%E5%8D%888.46.48.png">
<meta property="og:image" content="https://github.com/zhangyongguang/learn-githug/raw/master/images/%E5%B1%8F%E5%B9%95%E5%BF%AB%E7%85%A7%202017-02-19%20%E4%B8%8B%E5%8D%888.48.46.png">
<meta property="og:image" content="https://github.com/zhangyongguang/learn-githug/raw/master/images/%E5%B1%8F%E5%B9%95%E5%BF%AB%E7%85%A7%202017-02-19%20%E4%B8%8B%E5%8D%888.50.24.png">
<meta property="og:image" content="https://github.com/zhangyongguang/learn-githug/raw/master/images/%E5%B1%8F%E5%B9%95%E5%BF%AB%E7%85%A7%202017-02-19%20%E4%B8%8B%E5%8D%888.52.02.png">
<meta property="og:image" content="https://github.com/zhangyongguang/learn-githug/raw/master/images/%E5%B1%8F%E5%B9%95%E5%BF%AB%E7%85%A7%202017-02-19%20%E4%B8%8B%E5%8D%888.53.35.png">
<meta property="og:image" content="https://github.com/zhangyongguang/learn-githug/raw/master/images/%E5%B1%8F%E5%B9%95%E5%BF%AB%E7%85%A7%202017-02-19%20%E4%B8%8B%E5%8D%888.57.09.png">
<meta property="og:image" content="https://github.com/zhangyongguang/learn-githug/raw/master/images/%E5%B1%8F%E5%B9%95%E5%BF%AB%E7%85%A7%202017-02-19%20%E4%B8%8B%E5%8D%889.00.48.png">
<meta property="og:updated_time" content="2018-05-28T08:47:51.279Z">
<meta name="twitter:card" content="summary">
<meta name="twitter:title" content="7.githug - git练习小工具">
<meta name="twitter:description" content="githug git练习小工具  githug这个命令行工具被设计来练习你的 Git 技能，它把平常可能遇到的一些场景都实例化，变成一个一个的关卡，一共有 55 个关卡，所以将他形象的形容为 Git 游戏。  安装githug1sudo gem install githug ) 游戏开始直接输入githug，再输入y，创建githug文件夹，就开始游戏了1githug  第一关根据提示初始化git">
<meta name="twitter:image" content="https://github.com/zhangyongguang/learn-githug/raw/master/images/%E5%B1%8F%E5%B9%95%E5%BF%AB%E7%85%A7%202017-02-19%20%E4%B8%8B%E5%8D%8812.57.50.png">



<script type="text/javascript" id="hexo.configurations">
  var NexT = window.NexT || {};
  var CONFIG = {
    root: '/',
    scheme: 'Gemini',
    version: '5.1.4',
    sidebar: {"position":"left","display":"post","offset":12,"b2t":false,"scrollpercent":false,"onmobile":false},
    fancybox: true,
    tabs: true,
    motion: {"enable":true,"async":false,"transition":{"post_block":"fadeIn","post_header":"slideDownIn","post_body":"slideDownIn","coll_header":"slideLeftIn","sidebar":"slideUpIn"}},
    duoshuo: {
      userId: '0',
      author: '博主'
    },
    algolia: {
      applicationID: '',
      apiKey: '',
      indexName: '',
      hits: {"per_page":10},
      labels: {"input_placeholder":"Search for Posts","hits_empty":"We didn't find any results for the search: ${query}","hits_stats":"${hits} results found in ${time} ms"}
    }
  };
</script>



  <link rel="canonical" href="http://yoursite.com/2017/12/25/2017-12-25-7.githug - git练习小工具/"/>





  <title>7.githug - git练习小工具 | 搁浅丶岁月的变迁</title>
  








</head>

<body itemscope itemtype="http://schema.org/WebPage" lang="zh-Hans">

  
  
    
  

  <div class="container sidebar-position-left page-post-detail">
    <div class="headband"></div>
    <a href="https://github.com/liaoren512"><img style="position: absolute; top: 0; left: 0; border: 0;" src="https://s3.amazonaws.com/github/ribbons/forkme_left_red_aa0000.png" alt="Fork me on GitHub"></a>
    <header id="header" class="header" itemscope itemtype="http://schema.org/WPHeader">
      <div class="header-inner"><div class="site-brand-wrapper">
  <div class="site-meta ">
    

    <div class="custom-logo-site-title">
      <a href="/"  class="brand" rel="start">
        <span class="logo-line-before"><i></i></span>
        <span class="site-title">搁浅丶岁月的变迁</span>
        <span class="logo-line-after"><i></i></span>
      </a>
    </div>
      
        <p class="site-subtitle">没有虽败犹荣，只有成王败寇。</p>
      
  </div>

  <div class="site-nav-toggle">
    <button>
      <span class="btn-bar"></span>
      <span class="btn-bar"></span>
      <span class="btn-bar"></span>
    </button>
  </div>
</div>

<nav class="site-nav">
  

  
    <ul id="menu" class="menu">
      
        
        <li class="menu-item menu-item-home">
          <a href="/" rel="section">
            
              <i class="menu-item-icon fa fa-fw fa-home"></i> <br />
            
            首页
          </a>
        </li>
      
        
        <li class="menu-item menu-item-tags">
          <a href="/tags/" rel="section">
            
              <i class="menu-item-icon fa fa-fw fa-tags"></i> <br />
            
            标签
          </a>
        </li>
      
        
        <li class="menu-item menu-item-categories">
          <a href="/categories/" rel="section">
            
              <i class="menu-item-icon fa fa-fw fa-th"></i> <br />
            
            分类
          </a>
        </li>
      
        
        <li class="menu-item menu-item-archives">
          <a href="/archives/" rel="section">
            
              <i class="menu-item-icon fa fa-fw fa-archive"></i> <br />
            
            归档
          </a>
        </li>
      

      
        <li class="menu-item menu-item-search">
          
            <a href="javascript:;" class="popup-trigger">
          
            
              <i class="menu-item-icon fa fa-search fa-fw"></i> <br />
            
            搜索
          </a>
        </li>
      
    </ul>
  

  
    <div class="site-search">
      
  <div class="popup search-popup local-search-popup">
  <div class="local-search-header clearfix">
    <span class="search-icon">
      <i class="fa fa-search"></i>
    </span>
    <span class="popup-btn-close">
      <i class="fa fa-times-circle"></i>
    </span>
    <div class="local-search-input-wrapper">
      <input autocomplete="off"
             placeholder="搜索..." spellcheck="false"
             type="text" id="local-search-input">
    </div>
  </div>
  <div id="local-search-result"></div>
</div>



    </div>
  
</nav>



 </div>
    </header>

    <main id="main" class="main">
      <div class="main-inner">
        <div class="content-wrap">
          <div id="content" class="content">
            

  <div id="posts" class="posts-expand">
    

  

  
  
  

  <article class="post post-type-normal" itemscope itemtype="http://schema.org/Article">
  
  
  
  <div class="post-block">
    <link itemprop="mainEntityOfPage" href="http://yoursite.com/2017/12/25/2017-12-25-7.githug - git练习小工具/">

    <span hidden itemprop="author" itemscope itemtype="http://schema.org/Person">
      <meta itemprop="name" content="廖壬">
      <meta itemprop="description" content="">
      <meta itemprop="image" content="/images/ichgo.jpg">
    </span>

    <span hidden itemprop="publisher" itemscope itemtype="http://schema.org/Organization">
      <meta itemprop="name" content="搁浅丶岁月的变迁">
    </span>

    
      <header class="post-header">

        
        
          <h1 class="post-title" itemprop="name headline">7.githug - git练习小工具</h1>
        

        <div class="post-meta">
          <span class="post-time">
            
              <span class="post-meta-item-icon">
                <i class="fa fa-calendar-o"></i>
              </span>
              
                <span class="post-meta-item-text">发表于</span>
              
              <time title="创建于" itemprop="dateCreated datePublished" datetime="2017-12-25T00:00:00+08:00">
                2017-12-25
              </time>
            

            

            
          </span>

          

          
            
          

          
          

          
            <span class="post-meta-divider">|</span>
            <span class="page-pv"><i class="fa fa-file-o"></i>
            <span class="busuanzi-value" id="busuanzi_value_page_pv" ></span>
            </span>
          

          
            <div class="post-wordcount">
              
                
                <span class="post-meta-item-icon">
                  <i class="fa fa-file-word-o"></i>
                </span>
                
                  <span class="post-meta-item-text">字数统计&#58;</span>
                
                <span title="字数统计">
                  
                </span>
              

              
                <span class="post-meta-divider">|</span>
              

              
                <span class="post-meta-item-icon">
                  <i class="fa fa-clock-o"></i>
                </span>
                
                  <span class="post-meta-item-text">阅读时长 &asymp;</span>
                
                <span title="阅读时长">
                  
                </span>
              
            </div>
          

          

        </div>
      </header>
    

    
    
    
    <div class="post-body" itemprop="articleBody">

      
      

      
        <h1 id="githug"><a href="#githug" class="headerlink" title="githug"></a>githug</h1><blockquote>
<p>git练习小工具</p>
</blockquote>
<p><strong>githug</strong>这个命令行工具被设计来练习你的 Git 技能，它把平常可能遇到的一些场景都实例化，变成一个一个的关卡，一共有 55 个关卡，所以将他形象的形容为 Git 游戏。</p>
<hr>
<h2 id="安装githug"><a href="#安装githug" class="headerlink" title="安装githug"></a>安装githug</h2><figure class="highlight cmake"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">sudo gem <span class="keyword">install</span> githug</span><br></pre></td></tr></table></figure>
<p><img src="https://github.com/zhangyongguang/learn-githug/raw/master/images/%E5%B1%8F%E5%B9%95%E5%BF%AB%E7%85%A7%202017-02-19%20%E4%B8%8B%E5%8D%8812.57.50.png" alt="Alt text">)</p>
<h2 id="游戏开始"><a href="#游戏开始" class="headerlink" title="游戏开始"></a>游戏开始</h2><p>直接输入githug，再输入y，创建githug文件夹，就开始游戏了<br><figure class="highlight ebnf"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line"><span class="attribute">githug</span></span><br></pre></td></tr></table></figure></p>
<p><img src="https://github.com/zhangyongguang/learn-githug/raw/master/images/%E5%B1%8F%E5%B9%95%E5%BF%AB%E7%85%A7%202017-02-19%20%E4%B8%8B%E5%8D%881.11.27.png" alt="这里写图片描述"></p>
<h2 id="第一关"><a href="#第一关" class="headerlink" title="第一关"></a>第一关</h2><p>根据提示初始化git_hug文件夹为仓库，初始化完成，执行githug play验证操作</p>
<p><img src="https://github.com/zhangyongguang/learn-githug/raw/master/images/%E5%B1%8F%E5%B9%95%E5%BF%AB%E7%85%A7%202017-02-19%20%E4%B8%8B%E5%8D%881.16.19.png" alt="这里写图片描述"><br><figure class="highlight bash"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br></pre></td><td class="code"><pre><span class="line"><span class="built_in">cd</span> git_hug/</span><br><span class="line">git init</span><br><span class="line">githug play</span><br></pre></td></tr></table></figure></p>
<h2 id="第二关"><a href="#第二关" class="headerlink" title="第二关"></a>第二关</h2><p>设置 Git 用户名和邮箱</p>
<p><img src="https://github.com/zhangyongguang/learn-githug/raw/master/images/%E5%B1%8F%E5%B9%95%E5%BF%AB%E7%85%A7%202017-02-19%20%E4%B8%8B%E5%8D%881.22.35.png" alt="这里写图片描述"><br><figure class="highlight routeros"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br></pre></td><td class="code"><pre><span class="line">git<span class="built_in"> config </span>--local user.name zhangyongguang</span><br><span class="line">git<span class="built_in"> config </span>--local user.email zyg5467@gmail.com</span><br><span class="line">githug play</span><br></pre></td></tr></table></figure></p>
<h2 id="第三关"><a href="#第三关" class="headerlink" title="第三关"></a>第三关</h2><p>把README文件加到暂存区</p>
<p><img src="https://github.com/zhangyongguang/learn-githug/raw/master/images/%E5%B1%8F%E5%B9%95%E5%BF%AB%E7%85%A7%202017-02-19%20%E4%B8%8B%E5%8D%881.29.17.png" alt="这里写图片描述"><br><figure class="highlight dockerfile"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br></pre></td><td class="code"><pre><span class="line">git <span class="keyword">add</span><span class="bash"> README</span></span><br><span class="line"><span class="bash">githug play</span></span><br></pre></td></tr></table></figure></p>
<h2 id="第四关"><a href="#第四关" class="headerlink" title="第四关"></a>第四关</h2><p>把README文件提交到仓库</p>
<p><img src="https://github.com/zhangyongguang/learn-githug/raw/master/images/%E5%B1%8F%E5%B9%95%E5%BF%AB%E7%85%A7%202017-02-19%20%E4%B8%8B%E5%8D%881.34.16.png" alt="这里写图片描述"><br><figure class="highlight mel"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br></pre></td><td class="code"><pre><span class="line">git commit -m <span class="string">"add README"</span></span><br><span class="line">githug <span class="keyword">play</span></span><br></pre></td></tr></table></figure></p>
<h2 id="第五关"><a href="#第五关" class="headerlink" title="第五关"></a>第五关</h2><p>克隆一个仓库</p>
<p><img src="https://github.com/zhangyongguang/learn-githug/raw/master/images/%E5%B1%8F%E5%B9%95%E5%BF%AB%E7%85%A7%202017-02-19%20%E4%B8%8B%E5%8D%881.37.27.png" alt="这里写图片描述"><br><figure class="highlight crmsh"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br></pre></td><td class="code"><pre><span class="line">git <span class="keyword">clone</span> <span class="title">https</span>://github.com/Gazler/cloneme</span><br><span class="line">githug play</span><br></pre></td></tr></table></figure></p>
<h2 id="第六关"><a href="#第六关" class="headerlink" title="第六关"></a>第六关</h2><p>克隆一个仓库，指定文件夹名</p>
<p><img src="https://github.com/zhangyongguang/learn-githug/raw/master/images/%E5%B1%8F%E5%B9%95%E5%BF%AB%E7%85%A7%202017-02-19%20%E4%B8%8B%E5%8D%881.39.59.png" alt="这里写图片描述"><br><figure class="highlight crmsh"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br></pre></td><td class="code"><pre><span class="line">git <span class="keyword">clone</span> <span class="title">https</span>://github.com/Gazler/cloneme my_cloned_repo</span><br><span class="line">githug play</span><br></pre></td></tr></table></figure></p>
<h2 id="第七关"><a href="#第七关" class="headerlink" title="第七关"></a>第七关</h2><p>忽略所有 .swp 后缀名的文件</p>
<p><img src="https://github.com/zhangyongguang/learn-githug/raw/master/images/%E5%B1%8F%E5%B9%95%E5%BF%AB%E7%85%A7%202017-02-19%20%E4%B8%8B%E5%8D%881.41.41.png" alt="这里写图片描述"><br><figure class="highlight ruby"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br></pre></td><td class="code"><pre><span class="line">echo <span class="string">"*.swp"</span> <span class="meta">&gt;&gt; </span>.gitignore</span><br><span class="line">githug play</span><br></pre></td></tr></table></figure></p>
<h2 id="第八关"><a href="#第八关" class="headerlink" title="第八关"></a>第八关</h2><p>除了 lib.a 文件，忽略其他 .a 后缀名的文件</p>
<p><img src="https://github.com/zhangyongguang/learn-githug/raw/master/images/%E5%B1%8F%E5%B9%95%E5%BF%AB%E7%85%A7%202017-02-19%20%E4%B8%8B%E5%8D%881.48.07.png" alt="这里写图片描述"><br><figure class="highlight ruby"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br></pre></td><td class="code"><pre><span class="line">echo -e <span class="string">'*.a\n!lib.a'</span> <span class="meta">&gt;&gt; </span>.gitignore</span><br><span class="line">githug play</span><br></pre></td></tr></table></figure></p>
<h2 id="第九关"><a href="#第九关" class="headerlink" title="第九关"></a>第九关</h2><p>查看当前仓库的状态，找到没有提交的文件</p>
<p><img src="https://github.com/zhangyongguang/learn-githug/raw/master/images/%E5%B1%8F%E5%B9%95%E5%BF%AB%E7%85%A7%202017-02-19%20%E4%B8%8B%E5%8D%881.56.55.png" alt="这里写图片描述"><br><figure class="highlight css"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br></pre></td><td class="code"><pre><span class="line"><span class="selector-tag">git</span> <span class="selector-tag">status</span></span><br><span class="line"><span class="selector-tag">githug</span> <span class="selector-tag">play</span></span><br><span class="line"><span class="selector-tag">database</span><span class="selector-class">.yml</span></span><br></pre></td></tr></table></figure></p>
<h2 id="第十关"><a href="#第十关" class="headerlink" title="第十关"></a>第十关</h2><p>查看当前仓库的状态，查看暂存区文件数</p>
<p><img src="https://github.com/zhangyongguang/learn-githug/raw/master/images/%E5%B1%8F%E5%B9%95%E5%BF%AB%E7%85%A7%202017-02-19%20%E4%B8%8B%E5%8D%882.01.42.png" alt="这里写图片描述"><br><figure class="highlight fortran"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br></pre></td><td class="code"><pre><span class="line">git <span class="keyword">status</span></span><br><span class="line">githug play</span><br><span class="line"><span class="number">2</span></span><br></pre></td></tr></table></figure></p>
<h2 id="第十一关"><a href="#第十一关" class="headerlink" title="第十一关"></a>第十一关</h2><p>从 git 仓库中删除</p>
<p><img src="https://github.com/zhangyongguang/learn-githug/raw/master/images/%E5%B1%8F%E5%B9%95%E5%BF%AB%E7%85%A7%202017-02-19%20%E4%B8%8B%E5%8D%886.32.43.png" alt="这里写图片描述"><br><figure class="highlight dockerfile"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br></pre></td><td class="code"><pre><span class="line">git <span class="keyword">add</span><span class="bash"> .</span></span><br><span class="line"><span class="bash">git commit -m <span class="string">"remove"</span></span></span><br><span class="line"><span class="bash">githug play</span></span><br></pre></td></tr></table></figure></p>
<h2 id="第十二关"><a href="#第十二关" class="headerlink" title="第十二关"></a>第十二关</h2><p>从 git 仓库中删除，不删除本地文件</p>
<p><img src="https://github.com/zhangyongguang/learn-githug/raw/master/images/%E5%B1%8F%E5%B9%95%E5%BF%AB%E7%85%A7%202017-02-19%20%E4%B8%8B%E5%8D%886.37.32.png" alt="这里写图片描述"><br><figure class="highlight stylus"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br></pre></td><td class="code"><pre><span class="line">git rm --cache deleteme.rb</span><br><span class="line">githug play</span><br></pre></td></tr></table></figure></p>
<h2 id="第十三关"><a href="#第十三关" class="headerlink" title="第十三关"></a>第十三关</h2><p>临时保存修改，但不提交到仓库</p>
<p><img src="https://github.com/zhangyongguang/learn-githug/raw/master/images/%E5%B1%8F%E5%B9%95%E5%BF%AB%E7%85%A7%202017-02-19%20%E4%B8%8B%E5%8D%886.40.05.png" alt="Alt text"><br><figure class="highlight ebnf"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br></pre></td><td class="code"><pre><span class="line"><span class="attribute">git stash</span></span><br><span class="line"><span class="attribute">githug play</span></span><br></pre></td></tr></table></figure></p>
<h2 id="第十四关"><a href="#第十四关" class="headerlink" title="第十四关"></a>第十四关</h2><p>重命名仓库文件</p>
<p><img src="https://github.com/zhangyongguang/learn-githug/raw/master/images/%E5%B1%8F%E5%B9%95%E5%BF%AB%E7%85%A7%202017-02-19%20%E4%B8%8B%E5%8D%886.40.05.png" alt="Alt text"><br><figure class="highlight stylus"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br></pre></td><td class="code"><pre><span class="line">git mv oldfile<span class="selector-class">.txt</span> newfile.txt</span><br><span class="line">githug play</span><br></pre></td></tr></table></figure></p>
<h2 id="第十五关"><a href="#第十五关" class="headerlink" title="第十五关"></a>第十五关</h2><p>移动所有 .html 文件到 src 文件夹</p>
<p><img src="https://github.com/zhangyongguang/learn-githug/raw/master/images/%E5%B1%8F%E5%B9%95%E5%BF%AB%E7%85%A7%202017-02-19%20%E4%B8%8B%E5%8D%886.46.39.png" alt="Alt text"><br><figure class="highlight nginx"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br></pre></td><td class="code"><pre><span class="line"><span class="attribute">mkdir</span> src</span><br><span class="line">git mv <span class="regexp">*.html</span> src</span><br><span class="line">githug play</span><br></pre></td></tr></table></figure></p>
<h2 id="第十六关"><a href="#第十六关" class="headerlink" title="第十六关"></a>第十六关</h2><p>找到最新的 commit 的 hash 值</p>
<p><img src="https://github.com/zhangyongguang/learn-githug/raw/master/images/%E5%B1%8F%E5%B9%95%E5%BF%AB%E7%85%A7%202017-02-19%20%E4%B8%8B%E5%8D%886.48.53.png" alt="这里写图片描述"><br><figure class="highlight mel"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br></pre></td><td class="code"><pre><span class="line">git <span class="keyword">log</span></span><br><span class="line">githug <span class="keyword">play</span></span><br><span class="line"><span class="number">00</span>d65157767dc30ad060fe316fefb22336a385c2</span><br></pre></td></tr></table></figure></p>
<h2 id="第十七关"><a href="#第十七关" class="headerlink" title="第十七关"></a>第十七关</h2><p>为最新的 commit 打 tag</p>
<p><img src="https://github.com/zhangyongguang/learn-githug/raw/master/images/%E5%B1%8F%E5%B9%95%E5%BF%AB%E7%85%A7%202017-02-19%20%E4%B8%8B%E5%8D%886.50.52.png" alt="Alt text"><br><figure class="highlight crmsh"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br></pre></td><td class="code"><pre><span class="line">git <span class="keyword">tag</span> <span class="title">new_tag</span></span><br><span class="line">githug play</span><br></pre></td></tr></table></figure></p>
<h2 id="第十八关"><a href="#第十八关" class="headerlink" title="第十八关"></a>第十八关</h2><p>将所有本地 tag 都推送到远端</p>
<p><img src="https://github.com/zhangyongguang/learn-githug/raw/master/images/%E5%B1%8F%E5%B9%95%E5%BF%AB%E7%85%A7%202017-02-19%20%E4%B8%8B%E5%8D%886.53.43.png" alt="Alt text"><br><figure class="highlight crmsh"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br></pre></td><td class="code"><pre><span class="line">git push --tags origin <span class="literal">master</span></span><br><span class="line">githug play</span><br></pre></td></tr></table></figure></p>
<h2 id="第十九关"><a href="#第十九关" class="headerlink" title="第十九关"></a>第十九关</h2><p>某个文件在上次提交漏了，在那次提交中补上这个文件。</p>
<p><img src="https://github.com/zhangyongguang/learn-githug/raw/master/images/%E5%B1%8F%E5%B9%95%E5%BF%AB%E7%85%A7%202017-02-19%20%E4%B8%8B%E5%8D%886.58.52.png" alt="Alt text"><br><figure class="highlight dockerfile"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br></pre></td><td class="code"><pre><span class="line">git <span class="keyword">add</span><span class="bash"> forgotten_file.rb</span></span><br><span class="line"><span class="bash">git commit --amend</span></span><br><span class="line"><span class="bash">:wq</span></span><br><span class="line"><span class="bash">githug play</span></span><br></pre></td></tr></table></figure></p>
<h2 id="第二十关"><a href="#第二十关" class="headerlink" title="第二十关"></a>第二十关</h2><p>为提交指定一个未来时间</p>
<p><img src="https://github.com/zhangyongguang/learn-githug/raw/master/images/%E5%B1%8F%E5%B9%95%E5%BF%AB%E7%85%A7%202017-02-19%20%E4%B8%8B%E5%8D%887.02.47.png" alt="Alt text"><br><figure class="highlight routeros"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br></pre></td><td class="code"><pre><span class="line">git commit <span class="attribute">--date</span>=20.02.2017T12:00:00</span><br><span class="line"><span class="builtin-name">add</span> README</span><br><span class="line">:wq</span><br><span class="line">githug play</span><br></pre></td></tr></table></figure></p>
<h2 id="第二十一关"><a href="#第二十一关" class="headerlink" title="第二十一关"></a>第二十一关</h2><p>用版本库文件覆盖暂存区文件</p>
<p><img src="https://github.com/zhangyongguang/learn-githug/raw/master/images/%E5%B1%8F%E5%B9%95%E5%BF%AB%E7%85%A7%202017-02-19%20%E4%B8%8B%E5%8D%887.11.59.png" alt="这里写图片描述"><br><figure class="highlight sql"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br></pre></td><td class="code"><pre><span class="line">git <span class="keyword">reset</span> <span class="keyword">HEAD</span> to_commit_second.rb</span><br><span class="line">githug play</span><br></pre></td></tr></table></figure></p>
<h2 id="第二十二关"><a href="#第二十二关" class="headerlink" title="第二十二关"></a>第二十二关</h2><p>撤销上一次提交，放到暂存区</p>
<p><img src="https://github.com/zhangyongguang/learn-githug/raw/master/images/%E5%B1%8F%E5%B9%95%E5%BF%AB%E7%85%A7%202017-02-19%20%E4%B8%8B%E5%8D%887.15.01.png" alt="这里写图片描述"><br><figure class="highlight mel"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br></pre></td><td class="code"><pre><span class="line">git reset --<span class="keyword">soft</span> HEAD^<span class="number">1</span></span><br><span class="line">githug <span class="keyword">play</span></span><br></pre></td></tr></table></figure></p>
<h2 id="第二十三关"><a href="#第二十三关" class="headerlink" title="第二十三关"></a>第二十三关</h2><p>抛弃本次修改，使用上次提交版本</p>
<p><img src="https://github.com/zhangyongguang/learn-githug/raw/master/images/%E5%B1%8F%E5%B9%95%E5%BF%AB%E7%85%A7%202017-02-19%20%E4%B8%8B%E5%8D%887.22.03.png" alt="这里写图片描述"><br><figure class="highlight stylus"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br></pre></td><td class="code"><pre><span class="line">git checkout config.rb</span><br><span class="line">githug play</span><br></pre></td></tr></table></figure></p>
<h2 id="第二十四关"><a href="#第二十四关" class="headerlink" title="第二十四关"></a>第二十四关</h2><p>查看远程仓库</p>
<p><img src="https://github.com/zhangyongguang/learn-githug/raw/master/images/%E5%B1%8F%E5%B9%95%E5%BF%AB%E7%85%A7%202017-02-19%20%E4%B8%8B%E5%8D%887.23.48.png" alt="这里写图片描述"><br><figure class="highlight mel"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br></pre></td><td class="code"><pre><span class="line">git remote -v</span><br><span class="line">githug <span class="keyword">play</span></span><br><span class="line">my_remote_repo</span><br></pre></td></tr></table></figure></p>
<h2 id="第二十五关"><a href="#第二十五关" class="headerlink" title="第二十五关"></a>第二十五关</h2><p>查看远程仓库URL</p>
<p><img src="https://github.com/zhangyongguang/learn-githug/raw/master/images/%E5%B1%8F%E5%B9%95%E5%BF%AB%E7%85%A7%202017-02-19%20%E4%B8%8B%E5%8D%887.25.36.png" alt="这里写图片描述"><br><figure class="highlight awk"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br></pre></td><td class="code"><pre><span class="line">git remote -v</span><br><span class="line">githug play</span><br><span class="line">https:<span class="regexp">//gi</span>thub.com<span class="regexp">/githug/</span>not_a_repo</span><br></pre></td></tr></table></figure></p>
<h2 id="第二十六关"><a href="#第二十六关" class="headerlink" title="第二十六关"></a>第二十六关</h2><p>拉取远端仓库</p>
<p><img src="https://github.com/zhangyongguang/learn-githug/raw/master/images/%E5%B1%8F%E5%B9%95%E5%BF%AB%E7%85%A7%202017-02-19%20%E4%B8%8B%E5%8D%887.28.05.png" alt="这里写图片描述"><br><figure class="highlight crmsh"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br></pre></td><td class="code"><pre><span class="line">git pull origin <span class="literal">master</span></span><br><span class="line">githug play</span><br></pre></td></tr></table></figure></p>
<h2 id="第二十七关"><a href="#第二十七关" class="headerlink" title="第二十七关"></a>第二十七关</h2><p>添加远程仓库</p>
<p><img src="https://github.com/zhangyongguang/learn-githug/raw/master/images/%E5%B1%8F%E5%B9%95%E5%BF%AB%E7%85%A7%202017-02-19%20%E4%B8%8B%E5%8D%887.29.54.png" alt="这里写图片描述"><br><figure class="highlight dockerfile"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br></pre></td><td class="code"><pre><span class="line">git remote <span class="keyword">add</span><span class="bash"> origin https://github.com/githug/githug</span></span><br><span class="line"><span class="bash">githug play</span></span><br></pre></td></tr></table></figure></p>
<h2 id="第二十八关"><a href="#第二十八关" class="headerlink" title="第二十八关"></a>第二十八关</h2><p>推送本地修改到远程</p>
<p><img src="https://github.com/zhangyongguang/learn-githug/raw/master/images/%E5%B1%8F%E5%B9%95%E5%BF%AB%E7%85%A7%202017-02-19%20%E4%B8%8B%E5%8D%887.32.27.png" alt="这里写图片描述"><br><figure class="highlight crmsh"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br></pre></td><td class="code"><pre><span class="line">git rebase origin/<span class="literal">master</span></span><br><span class="line">git push origin <span class="literal">master</span></span><br><span class="line">githug play</span><br></pre></td></tr></table></figure></p>
<h2 id="第二十九关"><a href="#第二十九关" class="headerlink" title="第二十九关"></a>第二十九关</h2><p>比较工作区与暂存区文件差异</p>
<p><img src="https://github.com/zhangyongguang/learn-githug/raw/master/images/%E5%B1%8F%E5%B9%95%E5%BF%AB%E7%85%A7%202017-02-19%20%E4%B8%8B%E5%8D%887.38.59.png" alt="这里写图片描述"><br><figure class="highlight lsl"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br></pre></td><td class="code"><pre><span class="line">git diff</span><br><span class="line">githug play</span><br><span class="line"><span class="number">26</span></span><br></pre></td></tr></table></figure></p>
<h2 id="第三十关"><a href="#第三十关" class="headerlink" title="第三十关"></a>第三十关</h2><p>查看某个文件的修改人</p>
<p><img src="https://github.com/zhangyongguang/learn-githug/raw/master/images/%E5%B1%8F%E5%B9%95%E5%BF%AB%E7%85%A7%202017-02-19%20%E4%B8%8B%E5%8D%887.44.24.png" alt="这里写图片描述"><br><figure class="highlight mipsasm"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br></pre></td><td class="code"><pre><span class="line">git <span class="keyword">blame </span><span class="built_in">config</span>.rb</span><br><span class="line">githug play</span><br><span class="line">Spider Man</span><br></pre></td></tr></table></figure></p>
<h2 id="第三十一关"><a href="#第三十一关" class="headerlink" title="第三十一关"></a>第三十一关</h2><p>创建一个分支</p>
<p><img src="https://github.com/zhangyongguang/learn-githug/raw/master/images/%E5%B1%8F%E5%B9%95%E5%BF%AB%E7%85%A7%202017-02-19%20%E4%B8%8B%E5%8D%888.37.42.png" alt="这里写图片描述"><br><figure class="highlight armasm"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br></pre></td><td class="code"><pre><span class="line"><span class="symbol">git</span> <span class="keyword">branch </span>test_code</span><br><span class="line"><span class="symbol">githug</span> play</span><br></pre></td></tr></table></figure></p>
<h2 id="第三十二关"><a href="#第三十二关" class="headerlink" title="第三十二关"></a>第三十二关</h2><p>创建一个分支并切换到该分支</p>
<p><img src="https://github.com/zhangyongguang/learn-githug/raw/master/images/%E5%B1%8F%E5%B9%95%E5%BF%AB%E7%85%A7%202017-02-19%20%E4%B8%8B%E5%8D%888.39.24.png" alt="这里写图片描述"><br><figure class="highlight stylus"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br></pre></td><td class="code"><pre><span class="line">git checkout -<span class="selector-tag">b</span> my_branch</span><br><span class="line">githug play</span><br></pre></td></tr></table></figure></p>
<h2 id="第三十三关"><a href="#第三十三关" class="headerlink" title="第三十三关"></a>第三十三关</h2><p>切换到某个特定的tag</p>
<p><img src="https://github.com/zhangyongguang/learn-githug/raw/master/images/%E5%B1%8F%E5%B9%95%E5%BF%AB%E7%85%A7%202017-02-19%20%E4%B8%8B%E5%8D%888.40.59.png" alt="这里写图片描述"><br><figure class="highlight crmsh"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br></pre></td><td class="code"><pre><span class="line">git <span class="keyword">tag</span></span><br><span class="line">git checkout v1.<span class="number">2</span></span><br><span class="line">githug play</span><br></pre></td></tr></table></figure></p>
<h2 id="第三十四关"><a href="#第三十四关" class="headerlink" title="第三十四关"></a>第三十四关</h2><p>切换到某个特定的tag，该tag与分支重名</p>
<p><img src="https://github.com/zhangyongguang/learn-githug/raw/master/images/%E5%B1%8F%E5%B9%95%E5%BF%AB%E7%85%A7%202017-02-19%20%E4%B8%8B%E5%8D%888.45.06.png" alt="这里写图片描述"><br><figure class="highlight crmsh"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br></pre></td><td class="code"><pre><span class="line">git <span class="keyword">tag</span></span><br><span class="line">git branch</span><br><span class="line">git checkout tags/v1.<span class="number">2</span></span><br><span class="line">githug play</span><br></pre></td></tr></table></figure></p>
<h2 id="第三十五关"><a href="#第三十五关" class="headerlink" title="第三十五关"></a>第三十五关</h2><p>根据上次提交创建新分支</p>
<p><img src="https://github.com/zhangyongguang/learn-githug/raw/master/images/%E5%B1%8F%E5%B9%95%E5%BF%AB%E7%85%A7%202017-02-19%20%E4%B8%8B%E5%8D%888.46.48.png" alt="这里写图片描述"><br><figure class="highlight armasm"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br></pre></td><td class="code"><pre><span class="line"><span class="symbol">git</span> <span class="keyword">branch </span>test_branch HEAD^</span><br><span class="line"><span class="symbol">githug</span> play</span><br></pre></td></tr></table></figure></p>
<h2 id="第三十六关"><a href="#第三十六关" class="headerlink" title="第三十六关"></a>第三十六关</h2><p>删除一个分支</p>
<p><img src="https://github.com/zhangyongguang/learn-githug/raw/master/images/%E5%B1%8F%E5%B9%95%E5%BF%AB%E7%85%A7%202017-02-19%20%E4%B8%8B%E5%8D%888.48.46.png" alt="这里写图片描述"><br><figure class="highlight armasm"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br></pre></td><td class="code"><pre><span class="line"><span class="symbol">git</span> <span class="keyword">branch </span>-d delete_me</span><br><span class="line"><span class="symbol">githug</span> play</span><br></pre></td></tr></table></figure></p>
<h2 id="第三十七关"><a href="#第三十七关" class="headerlink" title="第三十七关"></a>第三十七关</h2><p>将分支推送到远程仓库</p>
<p><img src="https://github.com/zhangyongguang/learn-githug/raw/master/images/%E5%B1%8F%E5%B9%95%E5%BF%AB%E7%85%A7%202017-02-19%20%E4%B8%8B%E5%8D%888.50.24.png" alt="这里写图片描述"><br><figure class="highlight maxima"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br></pre></td><td class="code"><pre><span class="line">git <span class="built_in">push</span> <span class="built_in">origin</span> test_branch</span><br><span class="line">githug play</span><br></pre></td></tr></table></figure></p>
<h2 id="第三十八关"><a href="#第三十八关" class="headerlink" title="第三十八关"></a>第三十八关</h2><p>合并分支</p>
<p><img src="https://github.com/zhangyongguang/learn-githug/raw/master/images/%E5%B1%8F%E5%B9%95%E5%BF%AB%E7%85%A7%202017-02-19%20%E4%B8%8B%E5%8D%888.52.02.png" alt="这里写图片描述"><br><figure class="highlight cos"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br></pre></td><td class="code"><pre><span class="line">git <span class="keyword">merge</span> feature</span><br><span class="line">githug play</span><br></pre></td></tr></table></figure></p>
<h2 id="第三十九关"><a href="#第三十九关" class="headerlink" title="第三十九关"></a>第三十九关</h2><p>获取远程仓库的修改</p>
<p><img src="https://github.com/zhangyongguang/learn-githug/raw/master/images/%E5%B1%8F%E5%B9%95%E5%BF%AB%E7%85%A7%202017-02-19%20%E4%B8%8B%E5%8D%888.53.35.png" alt="这里写图片描述"><br><figure class="highlight ebnf"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br></pre></td><td class="code"><pre><span class="line"><span class="attribute">git fetch origin</span></span><br><span class="line"><span class="attribute">githug play</span></span><br></pre></td></tr></table></figure></p>
<h2 id="第四十关"><a href="#第四十关" class="headerlink" title="第四十关"></a>第四十关</h2><p>移动到分支下游</p>
<p><img src="https://github.com/zhangyongguang/learn-githug/raw/master/images/%E5%B1%8F%E5%B9%95%E5%BF%AB%E7%85%A7%202017-02-19%20%E4%B8%8B%E5%8D%888.57.09.png" alt="这里写图片描述"><br><figure class="highlight crmsh"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br></pre></td><td class="code"><pre><span class="line">git rebase <span class="keyword">master</span> <span class="title">feature</span></span><br><span class="line">githug play</span><br></pre></td></tr></table></figure></p>
<h2 id="第四十一关"><a href="#第四十一关" class="headerlink" title="第四十一关"></a>第四十一关</h2><p>取出 client 分支，找出 client 分支和 server 分支的共同祖先之后的变化，然后把它们在 master 重演一遍</p>
<p><img src="https://github.com/zhangyongguang/learn-githug/raw/master/images/%E5%B1%8F%E5%B9%95%E5%BF%AB%E7%85%A7%202017-02-19%20%E4%B8%8B%E5%8D%889.00.48.png" alt="这里写图片描述"><br><figure class="highlight plain"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">未完待续。。。</span><br></pre></td></tr></table></figure></p>

      
    </div>
    
    
    

    <div>
      
        <div>
    
        <div style="text-align:center;color: #ccc;font-size:14px;">-------------本文结束<i class="fa fa-paw"></i>感谢您的阅读-------------</div>
    
</div>

      
    </div>

    

    

    

    <footer class="post-footer">
      
        <div class="post-tags">
          
            <!--<a href="/tags/git/" rel="tag"># git</a>-->
            <a href="/tags/git/" rel="tag"><i class="fa fa-tag"></i> git</a>
          
        </div>
      

      
      
      

      
        <div class="post-nav">
          <div class="post-nav-next post-nav-item">
            
              <a href="/2017/12/25/2017-12-25-6.调试---拨号/" rel="next" title="6.调试---拨号">
                <i class="fa fa-chevron-left"></i> 6.调试---拨号
              </a>
            
          </div>

          <span class="post-nav-divider"></span>

          <div class="post-nav-prev post-nav-item">
            
              <a href="/2017/12/25/2017-12-25-6.web层/" rel="prev" title="6.web层">
                6.web层 <i class="fa fa-chevron-right"></i>
              </a>
            
          </div>
        </div>
      

      
      
    </footer>
  </div>
  
  
  
  </article>



    <div class="post-spread">
      
        <!-- JiaThis Button BEGIN -->
<div class="jiathis_style">
<span class="jiathis_txt">分享到：</span>
<a class="jiathis_button_fav">收藏夹</a>
<a class="jiathis_button_copy">复制网址</a>
<a class="jiathis_button_email">邮件</a>
<a class="jiathis_button_weixin">微信</a>
<a class="jiathis_button_qzone">QQ空间</a>
<a class="jiathis_button_tqq">腾讯微博</a>
<a class="jiathis_button_douban">豆瓣</a>
<a class="jiathis_button_share">一键分享</a>

<a href="http://www.jiathis.com/share?uid=2140465" class="jiathis jiathis_txt jiathis_separator jtico jtico_jiathis" target="_blank">更多</a>
<a class="jiathis_counter_style"></a>
</div>
<script type="text/javascript" >
var jiathis_config={
  data_track_clickback:true,
  summary:"",
  shortUrl:false,
  hideMore:false
}
</script>
<script type="text/javascript" src="http://v3.jiathis.com/code/jia.js?uid=" charset="utf-8"></script>
<!-- JiaThis Button END -->
      
    </div>
  </div>


          </div>
          


          

  



        </div>
        
          
  
  <div class="sidebar-toggle">
    <div class="sidebar-toggle-line-wrap">
      <span class="sidebar-toggle-line sidebar-toggle-line-first"></span>
      <span class="sidebar-toggle-line sidebar-toggle-line-middle"></span>
      <span class="sidebar-toggle-line sidebar-toggle-line-last"></span>
    </div>
  </div>

  <aside id="sidebar" class="sidebar">
    
    <div class="sidebar-inner">

      

      
        <ul class="sidebar-nav motion-element">
          <li class="sidebar-nav-toc sidebar-nav-active" data-target="post-toc-wrap">
            文章目录
          </li>
          <li class="sidebar-nav-overview" data-target="site-overview-wrap">
            站点概览
          </li>
        </ul>
      

      <section class="site-overview-wrap sidebar-panel">
        <div class="site-overview">
          <div class="site-author motion-element" itemprop="author" itemscope itemtype="http://schema.org/Person">
            
              <img class="site-author-image" itemprop="image"
                src="/images/ichgo.jpg"
                alt="廖壬" />
            
              <p class="site-author-name" itemprop="name">廖壬</p>
              <p class="site-description motion-element" itemprop="description">Learn to choose, to forsake, to endure loneliness, to resist temptation.</p>
          </div>

          <nav class="site-state motion-element">

            
              <div class="site-state-item site-state-posts">
              
                <a href="/archives/">
              
                  <span class="site-state-item-count">391</span>
                  <span class="site-state-item-name">日志</span>
                </a>
              </div>
            

            
              
              
              <div class="site-state-item site-state-categories">
                <a href="/categories/index.html">
                  <span class="site-state-item-count">11</span>
                  <span class="site-state-item-name">分类</span>
                </a>
              </div>
            

            
              
              
              <div class="site-state-item site-state-tags">
                <a href="/tags/index.html">
                  <span class="site-state-item-count">56</span>
                  <span class="site-state-item-name">标签</span>
                </a>
              </div>
            

          </nav>

          
            <div class="feed-link motion-element">
              <a href="/atom.xml" rel="alternate">
                <i class="fa fa-rss"></i>
                RSS
              </a>
            </div>
          

          
            <div class="links-of-author motion-element">
                
                  <span class="links-of-author-item">
                    <a href="https://github.com/liaoren512" target="_blank" title="GitHub">
                      
                        <i class="fa fa-fw fa-github"></i>GitHub</a>
                  </span>
                
                  <span class="links-of-author-item">
                    <a href="mailto:liaoren512@gmail.com" target="_blank" title="E-Mail">
                      
                        <i class="fa fa-fw fa-envelope"></i>E-Mail</a>
                  </span>
                
                  <span class="links-of-author-item">
                    <a href="https://weibo.com/5281757990/profile?rightmod=1&wvr=6&mod=personinfo" target="_blank" title="Weibo">
                      
                        <i class="fa fa-fw fa-globe"></i>Weibo</a>
                  </span>
                
                  <span class="links-of-author-item">
                    <a href="https://www.zhihu.com" target="_blank" title="Zhihu">
                      
                        <i class="fa fa-fw fa-globe"></i>Zhihu</a>
                  </span>
                
            </div>
          

          
          

          
          

          

        </div>
      </section>

      
      <!--noindex-->
        <section class="post-toc-wrap motion-element sidebar-panel sidebar-panel-active">
          <div class="post-toc">

            
              
            

            
              <div class="post-toc-content"><ol class="nav"><li class="nav-item nav-level-1"><a class="nav-link" href="#githug"><span class="nav-number">1.</span> <span class="nav-text">githug</span></a><ol class="nav-child"><li class="nav-item nav-level-2"><a class="nav-link" href="#安装githug"><span class="nav-number">1.1.</span> <span class="nav-text">安装githug</span></a></li><li class="nav-item nav-level-2"><a class="nav-link" href="#游戏开始"><span class="nav-number">1.2.</span> <span class="nav-text">游戏开始</span></a></li><li class="nav-item nav-level-2"><a class="nav-link" href="#第一关"><span class="nav-number">1.3.</span> <span class="nav-text">第一关</span></a></li><li class="nav-item nav-level-2"><a class="nav-link" href="#第二关"><span class="nav-number">1.4.</span> <span class="nav-text">第二关</span></a></li><li class="nav-item nav-level-2"><a class="nav-link" href="#第三关"><span class="nav-number">1.5.</span> <span class="nav-text">第三关</span></a></li><li class="nav-item nav-level-2"><a class="nav-link" href="#第四关"><span class="nav-number">1.6.</span> <span class="nav-text">第四关</span></a></li><li class="nav-item nav-level-2"><a class="nav-link" href="#第五关"><span class="nav-number">1.7.</span> <span class="nav-text">第五关</span></a></li><li class="nav-item nav-level-2"><a class="nav-link" href="#第六关"><span class="nav-number">1.8.</span> <span class="nav-text">第六关</span></a></li><li class="nav-item nav-level-2"><a class="nav-link" href="#第七关"><span class="nav-number">1.9.</span> <span class="nav-text">第七关</span></a></li><li class="nav-item nav-level-2"><a class="nav-link" href="#第八关"><span class="nav-number">1.10.</span> <span class="nav-text">第八关</span></a></li><li class="nav-item nav-level-2"><a class="nav-link" href="#第九关"><span class="nav-number">1.11.</span> <span class="nav-text">第九关</span></a></li><li class="nav-item nav-level-2"><a class="nav-link" href="#第十关"><span class="nav-number">1.12.</span> <span class="nav-text">第十关</span></a></li><li class="nav-item nav-level-2"><a class="nav-link" href="#第十一关"><span class="nav-number">1.13.</span> <span class="nav-text">第十一关</span></a></li><li class="nav-item nav-level-2"><a class="nav-link" href="#第十二关"><span class="nav-number">1.14.</span> <span class="nav-text">第十二关</span></a></li><li class="nav-item nav-level-2"><a class="nav-link" href="#第十三关"><span class="nav-number">1.15.</span> <span class="nav-text">第十三关</span></a></li><li class="nav-item nav-level-2"><a class="nav-link" href="#第十四关"><span class="nav-number">1.16.</span> <span class="nav-text">第十四关</span></a></li><li class="nav-item nav-level-2"><a class="nav-link" href="#第十五关"><span class="nav-number">1.17.</span> <span class="nav-text">第十五关</span></a></li><li class="nav-item nav-level-2"><a class="nav-link" href="#第十六关"><span class="nav-number">1.18.</span> <span class="nav-text">第十六关</span></a></li><li class="nav-item nav-level-2"><a class="nav-link" href="#第十七关"><span class="nav-number">1.19.</span> <span class="nav-text">第十七关</span></a></li><li class="nav-item nav-level-2"><a class="nav-link" href="#第十八关"><span class="nav-number">1.20.</span> <span class="nav-text">第十八关</span></a></li><li class="nav-item nav-level-2"><a class="nav-link" href="#第十九关"><span class="nav-number">1.21.</span> <span class="nav-text">第十九关</span></a></li><li class="nav-item nav-level-2"><a class="nav-link" href="#第二十关"><span class="nav-number">1.22.</span> <span class="nav-text">第二十关</span></a></li><li class="nav-item nav-level-2"><a class="nav-link" href="#第二十一关"><span class="nav-number">1.23.</span> <span class="nav-text">第二十一关</span></a></li><li class="nav-item nav-level-2"><a class="nav-link" href="#第二十二关"><span class="nav-number">1.24.</span> <span class="nav-text">第二十二关</span></a></li><li class="nav-item nav-level-2"><a class="nav-link" href="#第二十三关"><span class="nav-number">1.25.</span> <span class="nav-text">第二十三关</span></a></li><li class="nav-item nav-level-2"><a class="nav-link" href="#第二十四关"><span class="nav-number">1.26.</span> <span class="nav-text">第二十四关</span></a></li><li class="nav-item nav-level-2"><a class="nav-link" href="#第二十五关"><span class="nav-number">1.27.</span> <span class="nav-text">第二十五关</span></a></li><li class="nav-item nav-level-2"><a class="nav-link" href="#第二十六关"><span class="nav-number">1.28.</span> <span class="nav-text">第二十六关</span></a></li><li class="nav-item nav-level-2"><a class="nav-link" href="#第二十七关"><span class="nav-number">1.29.</span> <span class="nav-text">第二十七关</span></a></li><li class="nav-item nav-level-2"><a class="nav-link" href="#第二十八关"><span class="nav-number">1.30.</span> <span class="nav-text">第二十八关</span></a></li><li class="nav-item nav-level-2"><a class="nav-link" href="#第二十九关"><span class="nav-number">1.31.</span> <span class="nav-text">第二十九关</span></a></li><li class="nav-item nav-level-2"><a class="nav-link" href="#第三十关"><span class="nav-number">1.32.</span> <span class="nav-text">第三十关</span></a></li><li class="nav-item nav-level-2"><a class="nav-link" href="#第三十一关"><span class="nav-number">1.33.</span> <span class="nav-text">第三十一关</span></a></li><li class="nav-item nav-level-2"><a class="nav-link" href="#第三十二关"><span class="nav-number">1.34.</span> <span class="nav-text">第三十二关</span></a></li><li class="nav-item nav-level-2"><a class="nav-link" href="#第三十三关"><span class="nav-number">1.35.</span> <span class="nav-text">第三十三关</span></a></li><li class="nav-item nav-level-2"><a class="nav-link" href="#第三十四关"><span class="nav-number">1.36.</span> <span class="nav-text">第三十四关</span></a></li><li class="nav-item nav-level-2"><a class="nav-link" href="#第三十五关"><span class="nav-number">1.37.</span> <span class="nav-text">第三十五关</span></a></li><li class="nav-item nav-level-2"><a class="nav-link" href="#第三十六关"><span class="nav-number">1.38.</span> <span class="nav-text">第三十六关</span></a></li><li class="nav-item nav-level-2"><a class="nav-link" href="#第三十七关"><span class="nav-number">1.39.</span> <span class="nav-text">第三十七关</span></a></li><li class="nav-item nav-level-2"><a class="nav-link" href="#第三十八关"><span class="nav-number">1.40.</span> <span class="nav-text">第三十八关</span></a></li><li class="nav-item nav-level-2"><a class="nav-link" href="#第三十九关"><span class="nav-number">1.41.</span> <span class="nav-text">第三十九关</span></a></li><li class="nav-item nav-level-2"><a class="nav-link" href="#第四十关"><span class="nav-number">1.42.</span> <span class="nav-text">第四十关</span></a></li><li class="nav-item nav-level-2"><a class="nav-link" href="#第四十一关"><span class="nav-number">1.43.</span> <span class="nav-text">第四十一关</span></a></li></ol></li></ol></div>
            

          </div>
        </section>
      <!--/noindex-->
      

      

    </div>
  </aside>


        
      </div>
    </main>

    <footer id="footer" class="footer">
      <div class="footer-inner">
        
<!--<script async src="https://dn-lbstatics.qbox.me/busuanzi/2.3/busuanzi.pure.mini.js"></script>-->

<div class="copyright">&copy; <span itemprop="copyrightYear">2018</span>
  <span class="with-love">
    <i class="fa fa-user"></i>
  </span>
  <span class="author" itemprop="copyrightHolder">廖壬</span>

  
</div>

<!-- 在网站底部加上访问量-->
<!--<div class="powered-by">
<i class="fa fa-user-md"></i><span id="busuanzi_container_site_uv">
  本站访客数:<span id="busuanzi_value_site_pv"></span>
</span>
</div>-->
<!--pv的方式，单个用户连续点击n篇文章，记录n次访问量-->
<!--

  <div class="powered-by">由 <a class="theme-link" target="_blank" href="https://hexo.io">Hexo</a> 强力驱动</div>



  <span class="post-meta-divider">|</span>



  <div class="theme-info">主题 &mdash; <a class="theme-link" target="_blank" href="https://github.com/iissnan/hexo-theme-next">NexT.Gemini</a> v5.1.4</div>



-->
<div class="theme-info">
  <div class="powered-by"></div>
  <span class="post-count">博客全站共字</span>
</div>
        
<div class="busuanzi-count">
  <script async src="https://dn-lbstatics.qbox.me/busuanzi/2.3/busuanzi.pure.mini.js"></script>

  
    <span class="site-uv">
      <i class="fa fa-user"></i>
      <span class="busuanzi-value" id="busuanzi_value_site_uv"></span>
      
    </span>
  

  
    <span class="site-pv">
      <i class="fa fa-eye"></i>
      <span class="busuanzi-value" id="busuanzi_value_site_pv"></span>
      
    </span>
  
</div>








        
      </div>
    </footer>

    
      <div class="back-to-top">
        <i class="fa fa-arrow-up"></i>
        
      </div>
    

    

  </div>

  

<script type="text/javascript">
  if (Object.prototype.toString.call(window.Promise) !== '[object Function]') {
    window.Promise = null;
  }
</script>









  


  



  
  









  
  
    <script type="text/javascript" src="/lib/jquery/index.js?v=2.1.3"></script>
  

  
  
    <script type="text/javascript" src="/lib/fastclick/lib/fastclick.min.js?v=1.0.6"></script>
  

  
  
    <script type="text/javascript" src="/lib/jquery_lazyload/jquery.lazyload.js?v=1.9.7"></script>
  

  
  
    <script type="text/javascript" src="/lib/velocity/velocity.min.js?v=1.2.1"></script>
  

  
  
    <script type="text/javascript" src="/lib/velocity/velocity.ui.min.js?v=1.2.1"></script>
  

  
  
    <script type="text/javascript" src="/lib/fancybox/source/jquery.fancybox.pack.js?v=2.1.5"></script>
  

  
  
    <script type="text/javascript" src="/lib/canvas-nest/canvas-nest.min.js"></script>
  

  
  
    <script type="text/javascript" src="/lib/three/three.min.js"></script>
  

  
  
    <script type="text/javascript" src="/lib/three/three-waves.min.js"></script>
  


  


  <script type="text/javascript" src="/js/src/utils.js?v=5.1.4"></script>

  <script type="text/javascript" src="/js/src/motion.js?v=5.1.4"></script>



  
  


  <script type="text/javascript" src="/js/src/affix.js?v=5.1.4"></script>

  <script type="text/javascript" src="/js/src/schemes/pisces.js?v=5.1.4"></script>



  
  <script type="text/javascript" src="/js/src/scrollspy.js?v=5.1.4"></script>
<script type="text/javascript" src="/js/src/post-details.js?v=5.1.4"></script>



  


  <script type="text/javascript" src="/js/src/bootstrap.js?v=5.1.4"></script>



  


  




	





  





  












  

  <script type="text/javascript">
    // Popup Window;
    var isfetched = false;
    var isXml = true;
    // Search DB path;
    var search_path = "search.xml";
    if (search_path.length === 0) {
      search_path = "search.xml";
    } else if (/json$/i.test(search_path)) {
      isXml = false;
    }
    var path = "/" + search_path;
    // monitor main search box;

    var onPopupClose = function (e) {
      $('.popup').hide();
      $('#local-search-input').val('');
      $('.search-result-list').remove();
      $('#no-result').remove();
      $(".local-search-pop-overlay").remove();
      $('body').css('overflow', '');
    }

    function proceedsearch() {
      $("body")
        .append('<div class="search-popup-overlay local-search-pop-overlay"></div>')
        .css('overflow', 'hidden');
      $('.search-popup-overlay').click(onPopupClose);
      $('.popup').toggle();
      var $localSearchInput = $('#local-search-input');
      $localSearchInput.attr("autocapitalize", "none");
      $localSearchInput.attr("autocorrect", "off");
      $localSearchInput.focus();
    }

    // search function;
    var searchFunc = function(path, search_id, content_id) {
      'use strict';

      // start loading animation
      $("body")
        .append('<div class="search-popup-overlay local-search-pop-overlay">' +
          '<div id="search-loading-icon">' +
          '<i class="fa fa-spinner fa-pulse fa-5x fa-fw"></i>' +
          '</div>' +
          '</div>')
        .css('overflow', 'hidden');
      $("#search-loading-icon").css('margin', '20% auto 0 auto').css('text-align', 'center');

      $.ajax({
        url: path,
        dataType: isXml ? "xml" : "json",
        async: true,
        success: function(res) {
          // get the contents from search data
          isfetched = true;
          $('.popup').detach().appendTo('.header-inner');
          var datas = isXml ? $("entry", res).map(function() {
            return {
              title: $("title", this).text(),
              content: $("content",this).text(),
              url: $("url" , this).text()
            };
          }).get() : res;
          var input = document.getElementById(search_id);
          var resultContent = document.getElementById(content_id);
          var inputEventFunction = function() {
            var searchText = input.value.trim().toLowerCase();
            var keywords = searchText.split(/[\s\-]+/);
            if (keywords.length > 1) {
              keywords.push(searchText);
            }
            var resultItems = [];
            if (searchText.length > 0) {
              // perform local searching
              datas.forEach(function(data) {
                var isMatch = false;
                var hitCount = 0;
                var searchTextCount = 0;
                var title = data.title.trim();
                var titleInLowerCase = title.toLowerCase();
                var content = data.content.trim().replace(/<[^>]+>/g,"");
                var contentInLowerCase = content.toLowerCase();
                var articleUrl = decodeURIComponent(data.url);
                var indexOfTitle = [];
                var indexOfContent = [];
                // only match articles with not empty titles
                if(title != '') {
                  keywords.forEach(function(keyword) {
                    function getIndexByWord(word, text, caseSensitive) {
                      var wordLen = word.length;
                      if (wordLen === 0) {
                        return [];
                      }
                      var startPosition = 0, position = [], index = [];
                      if (!caseSensitive) {
                        text = text.toLowerCase();
                        word = word.toLowerCase();
                      }
                      while ((position = text.indexOf(word, startPosition)) > -1) {
                        index.push({position: position, word: word});
                        startPosition = position + wordLen;
                      }
                      return index;
                    }

                    indexOfTitle = indexOfTitle.concat(getIndexByWord(keyword, titleInLowerCase, false));
                    indexOfContent = indexOfContent.concat(getIndexByWord(keyword, contentInLowerCase, false));
                  });
                  if (indexOfTitle.length > 0 || indexOfContent.length > 0) {
                    isMatch = true;
                    hitCount = indexOfTitle.length + indexOfContent.length;
                  }
                }

                // show search results

                if (isMatch) {
                  // sort index by position of keyword

                  [indexOfTitle, indexOfContent].forEach(function (index) {
                    index.sort(function (itemLeft, itemRight) {
                      if (itemRight.position !== itemLeft.position) {
                        return itemRight.position - itemLeft.position;
                      } else {
                        return itemLeft.word.length - itemRight.word.length;
                      }
                    });
                  });

                  // merge hits into slices

                  function mergeIntoSlice(text, start, end, index) {
                    var item = index[index.length - 1];
                    var position = item.position;
                    var word = item.word;
                    var hits = [];
                    var searchTextCountInSlice = 0;
                    while (position + word.length <= end && index.length != 0) {
                      if (word === searchText) {
                        searchTextCountInSlice++;
                      }
                      hits.push({position: position, length: word.length});
                      var wordEnd = position + word.length;

                      // move to next position of hit

                      index.pop();
                      while (index.length != 0) {
                        item = index[index.length - 1];
                        position = item.position;
                        word = item.word;
                        if (wordEnd > position) {
                          index.pop();
                        } else {
                          break;
                        }
                      }
                    }
                    searchTextCount += searchTextCountInSlice;
                    return {
                      hits: hits,
                      start: start,
                      end: end,
                      searchTextCount: searchTextCountInSlice
                    };
                  }

                  var slicesOfTitle = [];
                  if (indexOfTitle.length != 0) {
                    slicesOfTitle.push(mergeIntoSlice(title, 0, title.length, indexOfTitle));
                  }

                  var slicesOfContent = [];
                  while (indexOfContent.length != 0) {
                    var item = indexOfContent[indexOfContent.length - 1];
                    var position = item.position;
                    var word = item.word;
                    // cut out 100 characters
                    var start = position - 20;
                    var end = position + 80;
                    if(start < 0){
                      start = 0;
                    }
                    if (end < position + word.length) {
                      end = position + word.length;
                    }
                    if(end > content.length){
                      end = content.length;
                    }
                    slicesOfContent.push(mergeIntoSlice(content, start, end, indexOfContent));
                  }

                  // sort slices in content by search text's count and hits' count

                  slicesOfContent.sort(function (sliceLeft, sliceRight) {
                    if (sliceLeft.searchTextCount !== sliceRight.searchTextCount) {
                      return sliceRight.searchTextCount - sliceLeft.searchTextCount;
                    } else if (sliceLeft.hits.length !== sliceRight.hits.length) {
                      return sliceRight.hits.length - sliceLeft.hits.length;
                    } else {
                      return sliceLeft.start - sliceRight.start;
                    }
                  });

                  // select top N slices in content

                  var upperBound = parseInt('1');
                  if (upperBound >= 0) {
                    slicesOfContent = slicesOfContent.slice(0, upperBound);
                  }

                  // highlight title and content

                  function highlightKeyword(text, slice) {
                    var result = '';
                    var prevEnd = slice.start;
                    slice.hits.forEach(function (hit) {
                      result += text.substring(prevEnd, hit.position);
                      var end = hit.position + hit.length;
                      result += '<b class="search-keyword">' + text.substring(hit.position, end) + '</b>';
                      prevEnd = end;
                    });
                    result += text.substring(prevEnd, slice.end);
                    return result;
                  }

                  var resultItem = '';

                  if (slicesOfTitle.length != 0) {
                    resultItem += "<li><a href='" + articleUrl + "' class='search-result-title'>" + highlightKeyword(title, slicesOfTitle[0]) + "</a>";
                  } else {
                    resultItem += "<li><a href='" + articleUrl + "' class='search-result-title'>" + title + "</a>";
                  }

                  slicesOfContent.forEach(function (slice) {
                    resultItem += "<a href='" + articleUrl + "'>" +
                      "<p class=\"search-result\">" + highlightKeyword(content, slice) +
                      "...</p>" + "</a>";
                  });

                  resultItem += "</li>";
                  resultItems.push({
                    item: resultItem,
                    searchTextCount: searchTextCount,
                    hitCount: hitCount,
                    id: resultItems.length
                  });
                }
              })
            };
            if (keywords.length === 1 && keywords[0] === "") {
              resultContent.innerHTML = '<div id="no-result"><i class="fa fa-search fa-5x" /></div>'
            } else if (resultItems.length === 0) {
              resultContent.innerHTML = '<div id="no-result"><i class="fa fa-frown-o fa-5x" /></div>'
            } else {
              resultItems.sort(function (resultLeft, resultRight) {
                if (resultLeft.searchTextCount !== resultRight.searchTextCount) {
                  return resultRight.searchTextCount - resultLeft.searchTextCount;
                } else if (resultLeft.hitCount !== resultRight.hitCount) {
                  return resultRight.hitCount - resultLeft.hitCount;
                } else {
                  return resultRight.id - resultLeft.id;
                }
              });
              var searchResultList = '<ul class=\"search-result-list\">';
              resultItems.forEach(function (result) {
                searchResultList += result.item;
              })
              searchResultList += "</ul>";
              resultContent.innerHTML = searchResultList;
            }
          }

          if ('auto' === 'auto') {
            input.addEventListener('input', inputEventFunction);
          } else {
            $('.search-icon').click(inputEventFunction);
            input.addEventListener('keypress', function (event) {
              if (event.keyCode === 13) {
                inputEventFunction();
              }
            });
          }

          // remove loading animation
          $(".local-search-pop-overlay").remove();
          $('body').css('overflow', '');

          proceedsearch();
        }
      });
    }

    // handle and trigger popup window;
    $('.popup-trigger').click(function(e) {
      e.stopPropagation();
      if (isfetched === false) {
        searchFunc(path, 'local-search-input', 'local-search-result');
      } else {
        proceedsearch();
      };
    });

    $('.popup-btn-close').click(onPopupClose);
    $('.popup').click(function(e){
      e.stopPropagation();
    });
    $(document).on('keyup', function (event) {
      var shouldDismissSearchPopup = event.which === 27 &&
        $('.search-popup').is(':visible');
      if (shouldDismissSearchPopup) {
        onPopupClose();
      }
    });
  </script>





  

  

  

  
  

  

  

  

</body>
</html>
<!-- 页面点击小红心 -->
<script type="text/javascript" src="/js/src/love.js"></script>